# -*- coding: utf-8 -*-

"""
Module implementing MainWindow.
"""
import pandas
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QMainWindow
from PyQt5 import QtWidgets
from Ui_le_action import Ui_MainWindow


class MainWindow(QMainWindow, Ui_MainWindow):
    """
    Class documentation goes here.
    """

    def __init__(self, parent=None):
        """
        Constructor

        @param parent reference to the parent widget
        @type QWidget
        """
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)

    @pyqtSlot()
    def on_pushButton_clicked(self):
        """
        Slot documentation goes here.
        """
        # TODO: not implemented yet
        # raise NotImplementedError
        my_dir = QtWidgets.QFileDialog.getOpenFileName(self, "标题", "/")

    @pyqtSlot()
    def on_pushButton_3_clicked(self):
        """
        Slot documentation goes here.
        """
        # TODO: not implemented yet
        # raise NotImplementedError
        # my_dir = QtWidgets.QFileDialog.getOpenFileName(self, "标题", "/")
        #print(self.lineEdit_3.text())
        #text_1 = self.lineEdit_3.text()
        #print(self.comboBox.currentText())
        #self.textBrowser.append(self.lineEdit_3.text())  # ---追加
        #self.textBrowser.setText(self.lineEdit_3.text())
        #print(self.dateEdit.text())
        #self.textBrowser.setdate(self.dateEdit.text())

        list_result = []
        list_result.append(self.dateEdit.text())
        list_result.append(self.lineEdit_2.text())
        list_result.append(self.lineEdit.text())
        list_result.append(self.comboBox.currentText())
        list_result.append(self.lineEdit_3.text())

        for item in list_result:
            self.textBrowser.append(item)

        dest_file = "工作计划表.xlsx"
        list_header = "日期 任务 计划完成时间 已完成 备注".split()
        df = pandas.DataFrame([list_result], columns=list_header)
        df.to_excel(dest_file, sheet_name='工作计划表', index=False, header=True)

        return list_result

    @pyqtSlot()
    def on_pushButton_4_clicked(self):
        """
        Slot documentation goes here.
        """
        self.textBrowser.setText('')


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    ui = MainWindow()
    ui.show()
    sys.exit(app.exec_())
